app.controller("brandController", function($scope,$controller,brandService) {

				$controller("baseController",{$scope:$scope});

				//读取列表数据绑定到表单中
				$scope.findAll = function() {
					brandService.findAll().success(function(data) {
						$scope.list = data;
					});
				}

				//根据分页查询
				$scope.findPage = function(page,rows){
					
					brandService.findPage(page,rows).success(function(data) {
						$scope.list = data.rows;
						$scope.paginationConf.totalItems = data.total;
					});
				}
				
				//保存
				$scope.save = function(){
					var object = brandService.add($scope.entity);
					if($scope.entity.id != null){
						object = brandService.update($scope.entity);
					}
					object.success(function(data){
						if(data.success){
							//添加成功，重新加载页面
							$scope.reloadList();
						}else{
							alert(data.message);
						}
					});
				}
				
				//点击修改
				$scope.findOne = function(id){
					brandService.findOne(id).success(function(data) {
						$scope.entity = data;
					});
				}
				
				
				//批量删除
				$scope.dele = function(){
					brandService.dele($scope.selectIds).success(function(data) {
						if(data.success){
							$scope.reloadList();//刷新列表
						}else{
							alert(data.message);
						}
					});
				}
				
				//定义搜索对象
				$scope.searchEntity = {};
				//条件查询
				$scope.search = function(page,rows){
					brandService.search(page,rows,$scope.searchEntity).success(function(data){
						$scope.list = data.rows;
						$scope.paginationConf.totalItems = data.total;
					});
					
				}
			});